package com.dylan.历史.java8.lambda表达式.练习题;

/**
 * Created by Dylan on 2018/7/19.
 *
 * 题目:
 * 编写一个静态方法andThen,它接收两个Runnable实例作为参数,并返回一个分别运行这两个实例的Runnable对象.
 */
public class 第7题 {

    public static void main(String[] args) {
        Thread t = new Thread(andThen(() -> System.out.println("运行Runnable1"), () -> System.out.println("运行Runnable2")));
        t.start();
    }


    static Runnable andThen(Runnable r1, Runnable r2) {
        return () -> {
            r1.run();
            r2.run();
        };
    }
}
